package com.bdqn.hospital.service.impl;

import com.bdqn.hospital.mapper.RegistryMapper;
import com.bdqn.hospital.mapper.ScheduleMapper;
import com.bdqn.hospital.pojo.Registry;
import com.bdqn.hospital.mapper.RegistryMapper;
import com.bdqn.hospital.pojo.Registry;
import com.bdqn.hospital.service.RegistryService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @version : 1.0
 * @Author :guogd
 * @createTime: 2023/03/01 14:56
 * @Description: com.bdqn.hospital.service.impl
 */
@Service
public class RegistryServiceImpl implements RegistryService {
    @Autowired
    private RegistryMapper registryMapper;
    @Autowired
    private ScheduleMapper scheduleMap;
    @Override
    public Integer addRegistry(Registry registry) {
        Integer row = registryMapper.addRegistry(registry);
        scheduleMap.addRemainingQuantity();
        if(row>0){
            return 1;
        }else {
            return 0;
        }
    }


    @Override
    public Registry getPayById(Integer registryId) {
        return registryMapper.getPayById(registryId);
    }

    @Override
    public PageInfo<Registry> getAll2(Integer curPage, Integer pageSize, String idCard, Integer userName, Integer status, Integer roomId, Integer userId) {
        PageHelper.startPage(curPage,pageSize);
        PageInfo<Registry> pageInfo=new PageInfo<>(registryMapper.getAll2(idCard,userName,status,roomId,userId));
        return pageInfo;
    }

    @Override
    public PageInfo<Registry> getAll(Integer curPage ,Integer pageSize,String idCard,Integer userName,Integer status, Integer userId) {
        PageHelper.startPage(curPage,pageSize);
        PageInfo<Registry> pageInfo=new PageInfo<>(registryMapper.getAll(idCard,userName,status,userId));
        return pageInfo;
    }

    @Override
    public Integer updStatus(Integer id, Integer status,Integer type) {
        return registryMapper.updStatus(id, status,type);
    }
}
